package cn.wawi.controller.data;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import cn.wawi.common.easyui.DataGrid;
import cn.wawi.controller.BaseController;
import cn.wawi.entity.data.Post;
import cn.wawi.utils.JsonUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/data_post")
public class PostController extends BaseController<Post>{
	
	
	@InitBinder({"trade","grade"})
	public void initBinder(WebDataBinder binder) {
		binder.setFieldDefaultPrefix("trade.");
		binder.setFieldDefaultPrefix("grade.");
	}
	/**
	 * 岗位列表,以json格式异步交互
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value="/list",method=RequestMethod.GET)
	public DataGrid list(HttpServletRequest request){
		return findAllByPage(request);
	}
	
	@ResponseBody
	@RequestMapping(value="/trees",method=RequestMethod.GET)
	public List<Map<String,Object>> trees(Long id){
		List<Post> list=postDao.findAll(null);
		List<Post> list1=skillDao.findSkillPost(id);
		return JsonUtil.getPost(list,list1);
	}
}
